import { createContext, useContext } from '@/hooks/core/useContext';
import type { InjectionKey, Ref } from 'vue';
import { ContractCanvasClass } from '../../_core/useContractCanvas';

export interface PDFViewContextProps {
  contractClass: ContractCanvasClass;
  contractPdfInfo: Ref<Record<string, string>>
  validateForm: PromiseFn
}

const key: InjectionKey<PDFViewContextProps> = Symbol();

export function createPDFViewContext(context: PDFViewContextProps) {
  return createContext<PDFViewContextProps>(context, key, {
    readonly: false,
    native: true,
  });
}

export function usePDFViewContext() {
  return useContext<PDFViewContextProps>(key);
}
